# 用来存储测试集群纳管时用到的一些主机命令


# 获取k8s token
kubectl create sa management-admin -n kube-system &> /dev/null; \
kubectl create clusterrolebinding management-admin --clusterrole=cluster-admin --serviceaccount=kube-system:management-admin &> /dev/null; \
key=$(kubectl get sa management-admin -o=custom-columns=:.secrets[0].name -n kube-system | grep 'management');\
token=$(kubectl -n kube-system get secret ${key} -o yaml | grep token: | awk '{print $2}' | base64 -d 2> /dev/null);\
echo $token

# 创建 token secret
kubectl create ns xxx && \
kubectl create secret generic manage-k8s-token --namespace=xxx --from-file=token=./k8s-token-test

# 创建bc
kubectl apply -f ./manage.yaml
